/*
 * @Author: weisheng
 * @Date: 2023-04-17 12:51:22
 * @LastEditTime: 2023-04-20 15:01:53
 * @LastEditors: weisheng
 * @Description:
 * @FilePath: \uniapp-vue3-fant-ts\src\api\DemoApi.ts
 * 记得注释
 */
import http from '@/http/HttpClient'
import BaseResponse from '@/model/BaseResponse'
import Chanel from '@/model/Chanel'
import UserInfo from '@/model/UserInfo'
// 这里将API方法统一管理
export default class DemoApi {
  /**
   * 登录
   */
  static login(data): Promise<BaseResponse<UserInfo>> {
    return http
      .server(data)
      .get(
        'bi-api/report/dataapi/login?phone=' +
          data.mobile +
          '&name=' +
          data.name +
          (data.project_code ? '&project_code=' + data.project_code || '' : '')
      )
      .then((res) => {
        return res.data
      })
  }

  static leaderLogin(data): Promise<BaseResponse<UserInfo>> {
    return http
      .server(data)
      .get('bi-api/report/dataapi/dirverLeader?phone=' + data.mobile + '&name=' + data.name)
      .then((res) => {
        return res.data
      })
  }

  /**
   * 初始化
   */
  static init(abortRequest: 'same' | 'all' | 'none' = 'none'): Promise<BaseResponse<Chanel[]>> {
    return http
      .server(abortRequest)
      .post('api/init', {}, {})
      .then((res) => {
        return res.data
      })
  }

  // 项目列表
  static projectList(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server(data)
      .get('bi-api/report/dataapi/xiangmu?mobile=' + data.COL_4, {})
      .then((res) => {
        return res.data
      })
  }

  // 客户列表
  static customerList(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server(data)
      .get('bi-api/report/dataapi/kehu?xiangmu_name=' + data.COL_1, {})
      .then((res) => {
        return res.data
      })
  }

  // 油品列表
  static oilList(): Promise<BaseResponse<Chanel[]>> {
    return http
      .server()
      .get('bi-api/report/dataapi/oilList', {})
      .then((res) => {
        return res.data
      })
  }

  // 提交数据
  static submit(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server()
      .post('/visual-api/paas/visualdev/OnlineDev/7164c3e7895f49fd0c4e2742e81cb726', data, {})
      .then((res) => {
        return res.data
      })
  }

  static duizhangsubmit(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server()
      .post('/visual-api/paas/visualdev/OnlineDev/63af99d0ee724d149a30b9a782397844', data, {})
      .then((res) => {
        return res.data
      })
  }

  // 加油历史纪录
  static history(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server()
      .get('bi-api/report/dataapi/history?mobile=' + data.mobile, {})
      .then((res) => {
        return res.data
      })
  }

  // 队长加油历史纪录
  static duizhanghistory(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server()
      .get('bi-api/report/dataapi/duizhanghistory?mobile=' + data.mobile, {})
      .then((res) => {
        return res.data
      })
  }

  // 采购管理
  static purchase(data): Promise<BaseResponse<Chanel[]>> {
    return http
      .server()
      .get('bi-api/report/dataapi/odsbuy?xiangmu_id=' + data.xiangmu_id, {})
      .then((res) => {
        return res.data
      })
  }

  static qiumidu(data) {
    return http
      .server()
      .get('bi-api/report/dataapi/qiumidu', {
        params: data
      })
      .then((res) => {
        return res.data
      })
  }
}
